package com.crm.ServiceImpl;

import com.crm.Service.VisiterService;
import com.crm.dao.VisiterDao;
import com.crm.daoImpl.VisiterDaoImpl;
import com.crm.pojo.Visiter;
import com.crm.pojo.VisiterVo;

import java.util.List;

/**
 * @version : 1.0
 * @auther : hjx
 * @Date : 2021/6/29
 * @Description : 实训
 */
public class VisiterServiceImpl implements VisiterService {

    @Override
    public Boolean addVisiter(Visiter visiter) {

        VisiterDao visiterDao = new VisiterDaoImpl();
        if (visiterDao.insertVisiter(visiter)) {
            return true;
        }

        return false;
    }

    @Override
    public List<VisiterVo> queryAllVisitVo() {
        VisiterDao visiterDao = new VisiterDaoImpl();
        List<VisiterVo> list = visiterDao.selectAllVisitVo();
        return list;
    }

    @Override
    public List<VisiterVo> queryVisitByName(String visitName) {
        VisiterDao visiterDao = new VisiterDaoImpl();
        List<VisiterVo> list = visiterDao.selectVisitByName(visitName);
        return list;
    }

    @Override
    public boolean deleteVisit(int visitId) {
        VisiterDao visiterDao = new VisiterDaoImpl();
        int i = visiterDao.deleteVisit(visitId);
        if (i == 1) {
            return true;
        }
        return false;
    }

    @Override
    public Visiter queryVisitById(int visitId) {
        VisiterDao visiterDao = new VisiterDaoImpl();
        Visiter visiter = visiterDao.queryVisitById(visitId);
        return visiter;
    }

    @Override
    public Boolean updateVisit(Visiter visiter) {
        VisiterDao visiterDao = new VisiterDaoImpl();
        if (visiterDao.updateVisit(visiter) == 1) {
            return true;
        }
        return false;
    }


}
